<cfsetting enablecfoutputonly="true" />
<!--- @@displayname: List Podcasts as teasers --->
<!--- @@author: Jeff Coughlin (jeff[at]jeffcoughlin[dot]com) --->
<!--- @@hashURL: true --->

<!--- import tag libraries --->
<cfimport taglib="/farcry/core/tags/webskin" prefix="skin" />

<cfscript>
  // Declare local variables
  lastGroupName = "default_empty";
  loopCount = 0;
  columnNumber = 0;
  stParam = structNew();
  variables.StartRow = 0; // Variable set from within the paginate tag
  stObj.recordsPerPage = 10;
  stObj.numberOfPageLinks = 5;
    
  //Filter By Category
  //lCategoryIds = arrayToList(stObj.aPodcastCategories);
  lCategoryIds = "";
  
  // create objects
  oJcPodcastEpisode = application.stplugins.jcPodcast.oJcPodcastEpisode;
  /*
  qEpisodes = oJcPodcastEpisode.getEpisodes(
      bActive = true,
      bJoinCategories = true,
      lCategoryIds = lCategoryIds,
      orderBy = 'catTitle, label'
      );
      */
  qEpisodes = oJcPodcastEpisode.getEpisodes(
      bActive = true,
      orderBy = 'publishDate desc, label asc'
      );
</cfscript>

<!--- Just one column --->
<!---
<cfset loopCount = 0 />
<cfloop query="qEpisodes">
  <cfset loopCount = loopCount +1 />
  <cfif loopCount eq 1>
    <cfoutput><ul class="jcPodcastTeaserList">#chr(10)##chr(13)#</cfoutput>
  </cfif>
  <skin:view typename="jcPodcastEpisode" objectid="#qEpisodes.objectId#" webskin="displayTeaserStandard" />
  <cfif loopCount eq qEpisodes.recordCount>
    <cfoutput></ul>#chr(10)##chr(13)#</cfoutput>
  </cfif>
</cfloop>
--->
<cfif qEpisodes.recordCount gt 0>
  <cfif qEpisodes.recordCount gt stObj.recordsPerPage>
    <skin:pagination qRecordSet="#qEpisodes#" recordsPerPage="#stObj.recordsPerPage#" pageLinks="#stObj.numberOfPageLinks#">
      <cfif stObject.currentRow eq 1>
        <cfoutput><ul class="jcPodcastTeaserList">#chr(10)##chr(13)#</cfoutput>
      </cfif>
      <skin:view typename="jcPodcastEpisode" objectid="#stObject.objectId#" webskin="displayTeaserStandard" />
      <cfif stObject.currentRow eq qEpisodes.recordCount>
        <cfoutput></ul>#chr(10)##chr(13)#</cfoutput>
      </cfif>
    </skin:pagination>
  <cfelse>
    <cfset loopCount = 0 />
    <cfloop query="qEpisodes">
      <cfset loopCount = loopCount +1 />
      <cfif loopCount eq 1>
        <cfoutput><ul class="jcPodcastTeaserList">#chr(10)##chr(13)#</cfoutput>
      </cfif>
      <skin:view typename="jcPodcastEpisode" objectid="#qEpisodes.objectId#" webskin="displayTeaserStandard" />
      <cfif loopCount eq qEpisodes.recordCount>
        <cfoutput></ul>#chr(10)##chr(13)#</cfoutput>
      </cfif>
    </cfloop>
  </cfif>
</cfif>



<cfsetting enablecfoutputonly="false" />